 import {request} from '../utils/request'

// const BASE_URL_RECEIVE = "http://dev.marketing.lbs.p.yufeiworld.com" 
// const BASE_URL_RECEIVE = "http://dev.gateway.lbs.p.yufeiworld.com"
const BASE_URL_RECEIVE = ""
/* 
	优惠劵管理
*/
// 优惠劵详情
export const requestCouponInfoDetail = (id: number) => {
	return request({
		url: BASE_URL_RECEIVE + `/admin/marketing/coupon/info/detail/${id}` ,
		method: "GET",
		header: {
			'content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
		}
	})
}

export type CouponInfoList = {
  couponName: string,
  couponType: number,
  pageNo: number,
  pageSize: number,
  status: number
}
// 查询优惠券列表
export const requestCouponInfoList = (couponInfoList: Partial<CouponInfoList>) => {
	return request({
		url: BASE_URL_RECEIVE + `/admin/marketing/coupon/info/list` ,
		method: "POST",
		data: couponInfoList
	})
}


export type QueryReceivet = {
  couponType: number,
  orderNo: string,
  pageNo: number,
  pageSize: number,
  receiveChannel: number,
  status: number,
  userId: number
}
// 查询领取记录列表
export const requestCouponInfoQueryReceivet = (queryReceivet: Partial<QueryReceivet>) => {
	return request({
		url: BASE_URL_RECEIVE + `/admin/marketing/coupon/info/queryReceive` ,
		method: "POST",
		data: queryReceivet
	})
}


export type CouponInfo = {
  applicable: string,
  businessId: number,
  couponName: string,
  couponType: number,
  describes: string,
  discountValue: number,
  endDate: string,
  exclusionType: number,
  id: number,
  maxDiscountAmount: number,
  maxUsageLimit: number,
  orderAmount: number,
  startDate: string,
  usageLimit: number
}
// 新增优惠券
export const requestCouponInfoSave = (couponInfo: Partial<CouponInfo>) => {
	return request({
		url: BASE_URL_RECEIVE + `/admin/marketing/coupon/info/save` ,
		method: "POST",
		data: couponInfo
	})
}


// 更新优惠券
export const requestCouponInfoUpdate = (couponInfo: Partial<CouponInfo>) => {
	return request({
		url: BASE_URL_RECEIVE + `/admin/marketing/coupon/info/update` ,
		method: "POST",
		data: couponInfo
	})
}


export type CouponStatus = {
	id: number,
	status: number
}
// 更新优惠券状态
export const requestCouponInfoUpdateStatus = (couponStatus: Partial<CouponStatus>) => {
	return request({
		url: BASE_URL_RECEIVE + `/admin/marketing/coupon/info/updateStatus` ,
		method: "POST",
		data: couponStatus
	})
}